home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
COM
/
ProTERM Mac1.2a.sit
/
ProTERM Mac1.2a
/
Macros
/
Contributed
/
David's Utilities
/
Catalogger
next >
Wrap
Text File
|
1996-07-20
|
6KB
|
195 lines
// Catalogger Utility
// Version 1.1 by David D. Miller 20-JUL-96
// dmiller@c4systm.com - email for updates and support
// Catalogger will make a text file listing of the contents of a directory.
FUNC main()
{
WIN_RUNNING(0);
SHARED STR tab = ". "; // <-- set this to what you want it to put in front
// of each line (one per level) [default]
SHARED INT gcount = 0;
SHARED INT tcount = 0;
SHARED INT fref, show_alias, show_type, alias_follow;
INT setupwin;
STR svfl, fldr, tmpl;
fldr = "";
svfl = FN_GETPATH(0)+"Catalog";
tmpl = D_NEW(100,100,150,502,256,"PT Catalogger") +
D_INPUT("WT+0 WL+1",1024,300,24,"Path to catalog:") +
D_BUTTON("WT+1 PR+4","Set Path") +
D_INPUT("PB+5 WL+0",1024,300,24,"Save catalog to:") +
D_PRESET(svfl) +
D_BUTTON("PB-23 PR+4","Set Save") +
D_INPUT("PB+15 WL+15",15,60,24,"Indent string:") +
D_PRESET(tab) +
D_TOGGLE("WT+55 WL+200","Follow folder aliases") +
D_TOGGLE("PB+0 WL+200","Show alias original") +
D_PRESET("1") +
D_TOGGLE("PB+0 WL+200","Show type/creator") +
D_DEFAULT("WB+0 WR-5","OK") +
D_BUTTON("WB-3 PL-10","Cancel");
setupwin = D_OPEN(tmpl);
D_SET(setupwin,"Show alias original","1");
WHILE (1)
{
SWITCH (D_EVENT(setupwin,12000,"BT"))
{
CASE "@CLOSE":
CASE "Cancel": {
D_CLOSE(setupwin);
END;
}
CASE "OK" : {
fldr = D_GET(setupwin,"Path to catalog:");
IF (fldr == "") { WIN_NOTE(4,"You haven't entered a "+
"path yet!"); CONTINUE; }
svfl = D_GET(setupwin,"Save catalog to:");
IF (svfl == "") { WIN_NOTE(4,"You haven't entered a "+
"save filename yet!"); CONTINUE; }
tab = D_GET(setupwin,"Indent string:");
alias_follow = NUM_STR(D_GET(setupwin,
"Follow folder aliases"));
show_alias = NUM_STR(D_GET(setupwin,
"Show alias original"));
show_type = NUM_STR(D_GET(setupwin,
"Show type/creator"));
D_CLOSE(setupwin);
BREAK;
}
CASE "Follow folder aliases": {
IF (D_GET(setupwin,"Follow folder aliases") == "1")
{ WIN_NOTE(4,"WARNING: Following folder aliases^M"+
"can cause an infinite loop is a^M"+
"circular reference is found.") }
}
CASE "Set Path": {
FN_SETPATH(0,D_GET(setupwin,"Path to catalog:"));
fldr = FN_PATH(0,"Select");
D_SET(setupwin,"Path to catalog:",fldr);
}
CASE "Set Save": {
FN_SETPATH(0,D_GET(setupwin,"Save Catalog to:"));
svfl = FN_SAVE(0,"Save Catalog As:",FN_WHAT(svfl));
D_SET(setupwin,"Save Catalog to:",svfl);
}
}
}
IF (alias_follow > -1)
{
SetupWin();
IF (F_EXISTS(svfl) != "") { F_DELETE(svfl); }
F_CREATE(svfl);
fref = F_OPEN(svfl,"rw");
f_print(fref,"Directory of "+FN_UNPK(fldr)+"^M");
scan(fldr,tab);
F_CLOSE(fref);
CloseWin();
INT view = WIN_NOTE(5,"Done! View the catalog file now?");
IF (view == 1) { UI_OPEN(svfl); }
}
RETURN();
}
FUNC scan(STR fldr, STR lnprf)
{
SHARED STR tab;
SHARED INT gcount, tcount, fref, alias_follow, show_alias, show_type;
SetWin("Scanning "+fldr+"...");
STR batch = FN_SCAN(fldr,"","");
INT count = 0;
INT error;
INT size = ARRAY_SIZE(batch,1);
tcount = tcount + size;
STR file, type, info;
WHILE (count < size)
{
count = count + 1;
gcount = gcount + 1;
IF (WinEvt() == "Stop") { CloseWin(); F_CLOSE(fref); END; }
SetProg((gcount * 100)/tcount);
file = FN_UNPK(ARRAY_GET(batch,count));
type = F_EXISTS(file);
info = F_GETINFO(file);
IF (type == "fldr")
{
IF (info != "") && (!alias_follow)
{
f_print(fref,lnprf+FN_WHAT(file)+":");
IF (show_alias)
{
f_print(fref," --> "+FN_UNPK(FN_RESOLVE(file,"")));
}
f_print(fref,"^M");
}
ELSE
{
f_print(fref,lnprf+FN_WHAT(file)+":");
IF (info != "") && (show_alias)
{
f_print(fref," --> "+FN_UNPK(FN_RESOLVE(file,"")));
}
f_print(fref,"^M");
scan(file+":",lnprf+tab)
}
}
ELSE
{
f_print(fref,lnprf+FN_WHAT(file));
IF (show_type)
{
f_print(fref," ("+STR_MID(info,2,4)+"/"+STR_MID(info,6,4)+")");
}
f_print(fref,"^M");
}
}
RETURN();
}
FUNC f_print(INT fref, STR text)
{
IO_WRITE(fref,STR_LEN(text),text);
RETURN();
}
FUNC SetupWin()
{
STR tmpl = D_NEW(0,20,60,600,128+256,"Catalogger Status")+
D_FORM("WT+0 WL+0",550,-1,"~form")+
D_PROG("WB-3 WL+0",13,500,"~prog")+
D_BUTTON("WB+0 WR+0","Stop");
SHARED INT statwin = D_OPEN(tmpl);
RETURN();
}
FUNC CloseWin()
{
SHARED INT statwin;
D_CLOSE(statwin);
RETURN();
}
FUNC SetWin(STR text)
{
SHARED INT statwin;
D_SET(statwin,"~form",text);
RETURN();
}
FUNC WinEvt()
{
SHARED INT statwin;
STR event = D_EVENT(statwin,1,"B");
IF (event == "~prog") { event = "" };
RETURN(event);
}
FUNC SetProg(INT val)
{
SHARED INT statwin;
D_SET(statwin,"~prog",STR_NUM(val));
RETURN();
}